// export default function (fn, delay) {
//     let timer = null
//     return function () {
//         let content = this;
//         let args = arguments;
//         if (timer) {
//             clearTimeout(timer)
//         }
//         timer = setTimeout(() => {
//             fn.apply(content, args)
//         }, delay)
//     }
// }

export default function (fn, delay) {
    let timer = null
    return  (args) => {
        if (timer) {
            clearTimeout(timer)
        }
        timer = setTimeout(() => {
            fn(args)
        }, delay)
    }
}

export const debouceString = `export default function (fn, delay) {
    let timer = null
    return function (args) {
        if (timer) {
            clearTimeout(timer)
        }
        timer = setTimeout(() => {
            fn(args)
        }, delay)
    }
}` 